package containers;

import java.awt.BorderLayout;

import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;

public class JDialogExample 
{
	private JFrame frame;
	private JLabel label;
	private JDialog dialog;
	
	public JDialogExample(String titleFrame,String label,String titleDialog, boolean modal)
	{
		frame = new JFrame();
		frame.setTitle(titleFrame);
		this.label = new JLabel(label);
		frame.getContentPane().add(this.label,BorderLayout.WEST);
		frame.pack();
		frame.setLocationRelativeTo(null);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setResizable(false);
		
		dialog = new JDialog(frame,titleDialog,modal);
		dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
		
		
	}
	
	public void frameSize(int x,int y)
	{
		this.frame.setSize(x,y);
	}
	
	public void dialogSize(int x, int y)
	{
		
		dialog.pack();
		dialog.setLocationRelativeTo(frame);
		this.dialog.setSize(x, y);
	}
	
	public void printFrame()
	{
		this.frame.setVisible(true);
		
	}
	
	public void printDialog() 
	{
		this.dialog.setVisible(true);
	}
}
